# 14.5 RenderFactory

JFinal 3.0 has undergone a complete overhaul of the render module, extracting the IRenderFactory interface. The original RenderFactory has become the default implementation of the interface, eliminating the previous IMainRenderFactory, IErrorRenderFactory, and IXmlRenderFactory interfaces. All extensions and customizations related to render can now be achieved by inheriting from RenderFactory. The 3.0 version of the render module allows for switching and customization of all renders, and the extension approach is entirely consistent. If older projects have extended IMainRenderFactory, they only need to be upgraded as follows:

public class MyRenderFactory extends RenderFactory {
  public Render getRender(String view) {
     return new MyRender(view);
  }
}
1
2
3
4
5

Similarly, if you have previously extended IErrorRenderFactory or IXmlRenderFactory, you only need to add the getErrorRender(...) and getXmlRender(...) methods to the MyRenderFactory class above. After the extension, configure it in configConstant as follows:

public void configConstant(Constants me) {
  me.setRenderFactory(new MyRenderFactory());
}
1
2
3

JFinal 3.0 adopts a completely consistent extension method for all renders, making it easier to learn, more convenient to use, and straightforward to upgrade. Additionally, the me() method in the original RenderFactory class has been discontinued. If older projects depend on this, they only need to change RenderFactory.me() directly to RenderManager.me().getRenderFactory().

Last Updated: 9/22/2023, 7:59:19 AM